package com.r7data.dbstruct.meta;

import com.r7data.dbstruct.code.DbConstantCode;
import com.r7data.dbstruct.entity.DbConnectionInfo;
import com.r7data.dbstruct.exception.DbStructException;

/**
 * meta 工厂类
 * @author admin
 *
 */
public class DbMetaFactory {
	
	/**
	 * 生成对应的 db meta
	 * @param dbInfo
	 * @return
	 * @throws DbStructException
	 */
	public static BaseDbMeta getDbMeta(DbConnectionInfo dbInfo) throws DbStructException{
		int dbType = dbInfo.getDbType();
		
		BaseDbMeta dbMeta = null;
		
		switch (dbType) {
		case DbConstantCode.database_oracle:
			dbMeta = new OracleDbMeta();
			
			break;
		case DbConstantCode.database_mysql:
			dbMeta = new MysqlDbMeta();
			break;
	
		default:
			throw new DbStructException("database does not support ... ");
		}
		
		if(dbMeta != null){
			dbMeta.setDbType(dbType);
		}
		
		return dbMeta;
	}
	
	
	
}
